/***************************************************************************
 * 
 * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved
 * $Id$ 
 * 
 **************************************************************************/
 
 /**
 * @file main.cpp
 * @author liutongren(liutongren@baidu.com)
 * @date 2015/08/08 12:49:03
 * @version $Revision$ 
 * @brief 
 *  
 **/
#include <stdio.h>
#include <iostream>
#include <string>
#include "object_pool.hpp"
using std::string;
using std::cout;
using std::endl;
class Student {
public:
    Student(){
        std::cout << "Student " << std::endl;
    }
    Student(int64_t id) {
        std::cout << "Student id:"<< id << std::endl;
    }
};
int main()
{
    util::ObjectPool<string> object_pool(10);
    for (int i = 0; i != 100; ++i) {
        std::cout << "before" << std::endl;
        std::string *res = object_pool.get_ptr();
        std::cout << "after" << std::endl;
        char buffer[100];
        snprintf(buffer, 100, "hello%d", i);
        *res = buffer;
        std::cout << "before give_back" << std::endl;
        object_pool.give_back(res);
        std::cout << "after give_back" << std::endl;
        std::cout << "content" << *res << "\tsize:"<< object_pool.size() << std::endl;
        
        //four = object_pool->get_ptr();
   
        //Student stu(i);
    }
    return 0;
}

/* vim: set ts=4 sw=4 sts=4 tw=100 */
